<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/css/bootstrap-switch.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-domain-add">
			<input id="opened" name="opened" type="hidden" value="0" >
			<div class="form-group">
				<label class="col-sm-3 control-label">URL域名：</label>
				<div class="col-sm-8">
					<input id="named" name="named" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">端口：</label>
				<div class="col-sm-8">
					<input id="port" name="port" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<input id="description" name="description" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">对外接口：</label>
				<div class="col-sm-8">
					<input type="checkbox" id="checked_opened" name="checked_opened" />
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">实际ip地址：</label>
				<div class="col-sm-8">
					<input id="ipv4" name="ipv4" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">实际端口：</label>
				<div class="col-sm-8">
					<input id="ipv4port" name="ipv4port" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">访问地址：</label>
				<div class="col-sm-8">
					<input id="url" name="url" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">post直接访问地址：</label>
				<div class="col-sm-8">
					<input id="posturl" name="posturl" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<!--<input id="remark" name="remark" class="form-control" type="text">-->
					<textarea  id="remark" name="remark" class="form-control"  rows="3" cols="20"></textarea>
				</div>
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/js/bootstrap-switch.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "module/domain"
		$("#form-domain-add").validate({
			rules:{
                port:{
                    required:true,
                    digits:true,
                },
				description:{
					required:true,
				},
                named:{
                    required:true,
                },
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/add", $('#form-domain-add').serialize());
			}
		});
        $("#checked_opened").bootstrapSwitch({
            onText:"√",
            offText:"×",
            onColor:"success",
            offColor:"default",
            size:"small",
            onSwitchChange: function(event,state) {
                console.log("state="+state);
                console.log(event);
                event
                if (state == true) {
                    $("#opened").val('1');
                } else {
                    $("#opened").val('0');
                }
            }
        });
	</script>
	<script th:inline="javascript">
        /*<![CDATA[*/
        var checked_state = [[${domain.opened}]];
        /*]]>*/
        if(checked_state=='1'){

            $('#checked_opened').bootstrapSwitch('state', true);
        }else{
            $('#checked_opened').bootstrapSwitch('state', false);
        }
        console.log("checked_state="+checked_state);
	</script>
</body>
</html>
